<?php
    class Permission_Model extends CI_Model{
        function __construct() {
          parent::__construct();
        }      
        function getAllPermission(){
            return $this->db->get('admin_permission')->result();
        }
        function getPermissionPaging($num,$offset){
            return $this->db->get('admin_permission',$num,$offset)->result();
        }
        function getNumPermission(){
            return $this->db->get('admin_permission')->num_rows();
        }
        function getPermissionByID($id){
          $this->db->where('permission_id',$id);
          return $this->db->get('admin_permission')->row();
        }
        function saveData($id,$data){          
            if($id!=0){
                $this->db->where('permission_id',$id);
              if($this->db->update('admin_permission',$data)){
                  return true;
              }else{
                  return false;
              }
            }else{
              if($this->db->insert('admin_permission',$data)){
                  return true;
              }else{
                  return false;
              }
            }
        }
        function delete($id){
            $this->db->where('permission_id',$id);
            $query = $this->db->delete('admin_permission');
            if($query){
                return true;
            }else{
                return false;
            }
        }
  }
?>
